﻿using System;
using System.Collections.Generic;
using netDxf;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Tables;

namespace TestDxfDocument
{
    class ModularToolingSystems
    {

        public static void MonoblockExtensionBridgesWithAdaptor(Dictionary<string, Object> data)  //带适配器的整体扩展桥
        {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线

            double pi = Math.PI;

            //double oal = 45.0; //Convert.ToDouble(data["oal"]);
            //double dcon = 10.0; //Convert.ToDouble(data["dcon"]);
            //double lpr = 20.0; //Convert.ToDouble(data["lpr"]);
            //double ls = 25.0; //Convert.ToDouble(data["ls"]);
            //double bdx = 60.0; //Convert.ToDouble(data["bdx"]);
            //double oaw = 20.0; //Convert.ToDouble(data["oaw"]);

            //string path = "E:\\dxfp\\MonoblockExtensionBridgesWithAdaptor.dxf"; // Convert.ToString(data["path"]);

            double oal = Convert.ToDouble(data["oal"]);
            double dcon = Convert.ToDouble(data["dcon"]);
            double lpr = Convert.ToDouble(data["lpr"]);
            double ls = Convert.ToDouble(data["ls"]);
            double bdx = Convert.ToDouble(data["bdx"]);
            double oaw = Convert.ToDouble(data["oaw"]);

            string path = Convert.ToString(data["path"]);

            double ang1 = Math.Asin(oaw / bdx);

            Vector2 p0 = new Vector2(0, 0);
            Vector2 p1 = fun.Polar(p0, 0.5 * pi, dcon / 2);
            Vector2 p2 = fun.Polar(p1, 0, ls);
            Vector2 p3 = new Vector2(p2.X, p0.Y + bdx / 2);
            Vector2 p4 = fun.Polar(p3, 0, lpr);
            Vector2 p5 = new Vector2(p2.X, p0.Y + 0.5 * bdx * Math.Cos(ang1));
            Vector2 p6 = fun.Polar(p5, 0, lpr / 2);
            Vector2 p7 = fun.Polar(p6, 0.5 * pi, 0.8 * (p3.Y - p5.Y));
            Vector2 p8 = fun.Polar(p4, 1.5 * pi, 0.6 * (p3.Y - p5.Y));
            Vector2 p1p = new Vector2(p1.X, p0.Y - p1.Y);
            Vector2 p2p = new Vector2(p2.X, p0.Y - p2.Y);
            Vector2 p3p = new Vector2(p3.X, p0.Y - p3.Y);
            Vector2 p4p = new Vector2(p4.X, p0.Y - p4.Y);
            Vector2 p5p = new Vector2(p5.X, p0.Y - p5.Y);
            Vector2 p6p = new Vector2(p6.X, p0.Y - p6.Y);
            Vector2 p7p = new Vector2(p7.X, p0.Y - p7.Y);
            Vector2 p8p = new Vector2(p8.X, p0.Y - p8.Y);

            Vector2 p0p = fun.Polar(p0, 0, bdx * 2);
            Vector2 p11 = fun.Polar(p0p, 0.5 * pi - ang1, bdx / 2);
            Vector2 p12 = new Vector2(2 * p0p.X - p11.X, p11.Y);
            Vector2 p13 = new Vector2(p12.X, p0p.Y - p12.Y);
            Vector2 p14 = new Vector2(p11.X, p0p.Y - p11.Y);

            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(p8));
            poly1.Vertexes.Add(new LwPolylineVertex(p4));
            poly1.Vertexes.Add(new LwPolylineVertex(p3));
            poly1.Vertexes.Add(new LwPolylineVertex(p2));
            poly1.Vertexes.Add(new LwPolylineVertex(p1));
            poly1.Vertexes.Add(new LwPolylineVertex(p1p));
            poly1.Vertexes.Add(new LwPolylineVertex(p2p));
            poly1.Vertexes.Add(new LwPolylineVertex(p3p));
            poly1.Vertexes.Add(new LwPolylineVertex(p4p));
            poly1.Vertexes.Add(new LwPolylineVertex(p8p));
            poly1.IsClosed = true;
            fun.PolyFill(dxf, poly1, 0.1, contour);

            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p8));
            poly2.Vertexes.Add(new LwPolylineVertex(p7));
            poly2.Vertexes.Add(new LwPolylineVertex(p6));
            poly2.Vertexes.Add(new LwPolylineVertex(p5));
            poly2.Vertexes.Add(new LwPolylineVertex(p5p));
            poly2.Vertexes.Add(new LwPolylineVertex(p6p));
            poly2.Vertexes.Add(new LwPolylineVertex(p7p));
            poly2.Vertexes.Add(new LwPolylineVertex(p8p));
            poly2.IsClosed = true;
            fun.PolyFill(dxf, poly2, 0.1, contour);

            Vector2[] line1 = { p6, p6p };
            fun.drawPlineOfw(dxf, line1, 0.1, contour);

            LwPolyline poly3 = new LwPolyline();
            poly3.Vertexes.Add(new LwPolylineVertex(p11));
            poly3.Vertexes[0].Bulge = Math.Tan(2 * ang1 / 4);
            poly3.Vertexes.Add(new LwPolylineVertex(p12));
            poly3.Vertexes.Add(new LwPolylineVertex(p13));
            poly3.Vertexes[2].Bulge = Math.Tan(2 * ang1 / 4);
            poly3.Vertexes.Add(new LwPolylineVertex(p14));
            poly3.Vertexes.Add(new LwPolylineVertex(p11));
            fun.PolyFill(dxf, poly3, 0.1, contour);

            LwPolyline poly4 = new LwPolyline();
            poly4.Vertexes.Add(new LwPolylineVertex(fun.Polar(p0p, 0, dcon / 2)));
            poly4.Vertexes[0].Bulge = Math.Tan(pi / 4);
            poly4.Vertexes.Add(new LwPolylineVertex(fun.Polar(p0p, pi, dcon / 2)));
            poly4.Vertexes[1].Bulge = Math.Tan(pi / 4);
            poly4.Vertexes.Add(new LwPolylineVertex(fun.Polar(p0p, 0, dcon / 2)));
            fun.PolyFill(dxf, poly4, 0.1, contour);

            Vector2[] cenline1 = { fun.Polar(p0, pi, 1), fun.Polar(p0, 0, oal + 1) };
            fun.drawPlinetype(dxf, cenline1, 0.15, centre, Linetype.Center);
            Vector2[] cenline2 = { fun.Polar(p0p, pi, 0.5 * oaw + 1), fun.Polar(p0p, 0, 0.5 * oaw + 1) };
            fun.drawPlinetype(dxf, cenline2, 0.15, centre, Linetype.Center);
            Vector2[] cenline3 = { fun.Polar(p0p, 0.5 * pi, 0.5 * bdx + 1), fun.Polar(p0p, 1.5 * pi, 0.5 * bdx + 1) };
            fun.drawPlinetype(dxf, cenline3, 0.15, centre, Linetype.Center);

            Arc arc1 = fun.DrawArc(new Vector2(p0p.X + bdx / 2, 0), p0p, new Vector2(p0p.X, p3.Y));

            Vector2 p15 = fun.getPointForArcandLine(p8, fun.Polar(p8, 0, 100), p0p, arc1);
            Vector2 p16 = fun.getPointForArcandLine(p7, fun.Polar(p7, 0, 100), p0p, arc1);
            Vector2 p17 = new Vector2(2 * p0p.X - p16.X, p16.Y);
            Vector2 p18 = new Vector2(2 * p0p.X - p15.X, p15.Y);
            Vector2 p19 = new Vector2(p18.X, p0p.Y - p18.Y);
            Vector2 p20 = new Vector2(p17.X, p0p.Y - p17.Y);
            Vector2 p21 = new Vector2(p16.X, p0p.Y - p16.Y);
            Vector2 p22 = new Vector2(p15.X, p0p.Y - p15.Y);

            Vector2[] xuline1 = { p15, p22 };
            fun.drawPlinetype(dxf, xuline1, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline2 = { p16, p21 };
            fun.drawPlinetype(dxf, xuline2, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline3 = { p17, p20 };
            fun.drawPlinetype(dxf, xuline3, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline4 = { p18, p19 };
            fun.drawPlinetype(dxf, xuline4, 0.15, refin, Linetype.Dashed);

            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = 0.5;
            double offset = 7;

            LinearDimension linedim1 = new LinearDimension(new Line(p3, p4), offset, 0, dimensionStyle);
            fun.dxflinedim(dxf, linedim1, lpr);

            LinearDimension linedim2 = new LinearDimension(new Line(p1, p1p), offset, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim2, dcon);

            LinearDimension linedim3 = new LinearDimension(new Line(p1p, p3p), offset * 2, 180, dimensionStyle);
            fun.dxflinedim(dxf, linedim3, ls);

            LinearDimension linedim4 = new LinearDimension(new Line(p4p, p1p), offset * 3, 180, dimensionStyle);
            fun.dxflinedim(dxf, linedim4, oal);

            LinearDimension linedim5 = new LinearDimension(new Line(fun.Polar(p0p, 0.5 * pi, 0.5 * bdx), fun.Polar(p0p, 1.5 * pi, 0.5 * bdx)), offset * 4, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim5, bdx);

            LinearDimension linedim6 = new LinearDimension(new Line(p13, p14), offset * 2, 180, dimensionStyle);
            fun.dxflinedim(dxf, linedim6, oaw);



            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void BridgeToolAdapter(Dictionary<string, Object> data)  //桥工具适配器
        {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线

            double pi = Math.PI;

            //double oal = 45.0; //Convert.ToDouble(data["oal"]);
            //double ls = 30.0; //Convert.ToDouble(data["ls"]);
            //double dcon = 15.0; //Convert.ToDouble(data["dcon"]);
            //double lf = 10.0; //Convert.ToDouble(data["lf"]);
            //double bdx = 60.0; //Convert.ToDouble(data["bdx"]);
            //double oaw = 36.0; //Convert.ToDouble(data["oaw"]);

            //string path = "E:\\dxfp\\BridgeToolAdapter.dxf"; // Convert.ToString(data["path"]);

            double oal = Convert.ToDouble(data["oal"]);
            double ls = Convert.ToDouble(data["ls"]);
            double dcon = Convert.ToDouble(data["dcon"]);
            double lf = Convert.ToDouble(data["lf"]);
            double bdx = Convert.ToDouble(data["bdx"]);
            double oaw = Convert.ToDouble(data["oaw"]);

            string path = Convert.ToString(data["path"]);

            double ang = Math.Asin(oaw / bdx);

            Vector2 p0 = new Vector2(0, 0);
            Vector2 p0p = fun.Polar(p0, 0, oal * 1.2);
            Vector2 p1 = fun.Polar(p0p, 0.5 * pi, dcon / 2);
            Vector2 p2 = fun.Polar(p1, 0, ls);
            Vector2 p3 = new Vector2(p2.X, p0p.Y + bdx / 2);
            Vector2 p4 = fun.Polar(p3, 0, lf);
            Vector2 p5 = fun.Polar(p4, 1.5 * pi, 0.05 * bdx);
            Vector2 p6 = fun.Polar(p5, 0, oal - ls - lf);
            Vector2 p7 = new Vector2(p3.X, 0.5 * bdx * Math.Cos(ang));
            Vector2 p8 = fun.Polar(p7, 0, oal - ls);
            Vector2 p1p = new Vector2(p1.X, p0p.Y - p1.Y);
            Vector2 p2p = new Vector2(p2.X, p0p.Y - p2.Y);
            Vector2 p3p = new Vector2(p3.X, p0p.Y - p3.Y);
            Vector2 p4p = new Vector2(p4.X, p0p.Y - p4.Y);
            Vector2 p5p = new Vector2(p5.X, p0p.Y - p5.Y);
            Vector2 p6p = new Vector2(p6.X, p0p.Y - p6.Y);
            Vector2 p7p = new Vector2(p7.X, p0p.Y - p7.Y);
            Vector2 p8p = new Vector2(p8.X, p0p.Y - p8.Y);

            Vector2 p11 = fun.Polar(p0, 0.5 * pi - ang, 0.5 * bdx);
            Vector2 p12 = new Vector2(p0.X - p11.X, p11.Y);
            Vector2 p13 = new Vector2(p12.X, p0.Y - p12.Y);
            Vector2 p14 = new Vector2(p11.X, p0.Y - p11.Y);

            Arc arc1 = fun.DrawArc(fun.Polar(p0, 0, bdx / 2), p0, fun.Polar(p0, 0.5 * pi, bdx / 2));

            Vector2 p15 = fun.getPointForArcandLine(p5, fun.Polar(p5, pi, 100), p0, arc1);
            Vector2 p16 = new Vector2(p0.X - p15.X, p15.Y);
            Vector2 p17 = new Vector2(p16.X, p0.Y - p16.Y);
            Vector2 p18 = new Vector2(p15.X, p0.Y - p15.Y);

            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(p6));
            poly1.Vertexes.Add(new LwPolylineVertex(p5));
            poly1.Vertexes.Add(new LwPolylineVertex(p4));
            poly1.Vertexes.Add(new LwPolylineVertex(p3));
            poly1.Vertexes.Add(new LwPolylineVertex(p2));
            poly1.Vertexes.Add(new LwPolylineVertex(p1));
            poly1.Vertexes.Add(new LwPolylineVertex(p1p));
            poly1.Vertexes.Add(new LwPolylineVertex(p2p));
            poly1.Vertexes.Add(new LwPolylineVertex(p3p));
            poly1.Vertexes.Add(new LwPolylineVertex(p4p));
            poly1.Vertexes.Add(new LwPolylineVertex(p5p));
            poly1.Vertexes.Add(new LwPolylineVertex(p6p));
            poly1.Vertexes.Add(new LwPolylineVertex(p6));
            fun.PolyFill(dxf, poly1, 0.1, contour);

            Vector2[] line1 = { p7, p8 };
            fun.drawPlineOfw(dxf, line1, 0.1, contour);
            Vector2[] line2 = { p7p, p8p };
            fun.drawPlineOfw(dxf, line2, 0.1, contour);
            Vector2[] line3 = { p2, p2p };
            fun.drawPlineOfw(dxf, line3, 0.1, contour);
            Vector2[] xuline1 = { p5, p5p };
            fun.drawPlinetype(dxf, xuline1, 0.15, refin, Linetype.Dashed);

            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p11));
            poly2.Vertexes[0].Bulge = Math.Tan(ang / 2);
            poly2.Vertexes.Add(new LwPolylineVertex(p12));
            poly2.Vertexes.Add(new LwPolylineVertex(p13));
            poly2.Vertexes[2].Bulge = Math.Tan(ang / 2);
            poly2.Vertexes.Add(new LwPolylineVertex(p14));
            poly2.Vertexes.Add(new LwPolylineVertex(p11));
            fun.PolyFill(dxf, poly2, 0.1, contour);

            Vector2[] line4 = { p15, p18 };
            fun.drawPlineOfw(dxf, line4, 0.1, contour);
            Vector2[] line5 = { p16, p17 };
            fun.drawPlineOfw(dxf, line5, 0.1, contour);

            Vector2[] cenline1 = { fun.Polar(p0, 0, 0.5 * oaw + 1), fun.Polar(p0, pi, 0.5 * oaw + 1) };
            fun.drawPlinetype(dxf, cenline1, 0.15, centre, Linetype.Center);
            Vector2[] cenline2 = { fun.Polar(p0, 0.5 * pi, 0.5 * bdx + 1), fun.Polar(p0, 1.5 * pi, 0.5 * bdx + 1) };
            fun.drawPlinetype(dxf, cenline2, 0.15, centre, Linetype.Center);
            Vector2[] cenline3 = { fun.Polar(p0p, pi, 1), fun.Polar(p0p, 0, oal + 1) };
            fun.drawPlinetype(dxf, cenline3, 0.15, centre, Linetype.Center);

            fun.drawcircle(dxf, p0, 2, 0.1, contour);
            fun.drawcircle(dxf, fun.Polar(p0, 0.5 * pi, 0.2 * bdx), 2, 0.1, contour);
            fun.drawcircle(dxf, fun.Polar(p0, 1.5 * pi, 0.2 * bdx), 2, 0.1, contour);

            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = 0.5;
            double offset = 7;

            LinearDimension linedim1 = new LinearDimension(new Line(fun.Polar(p0, 0.5 * pi, bdx / 2), fun.Polar(p0, 1.5 * pi, bdx / 2)), offset * 4, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim1, bdx);

            LinearDimension linedim2 = new LinearDimension(new Line(p13, p14), offset * 2, 180, dimensionStyle);
            fun.dxflinedim(dxf, linedim2, oaw);

            LinearDimension linedim3 = new LinearDimension(new Line(p3, p4), offset, 0, dimensionStyle);
            fun.dxflinedim(dxf, linedim3, lf);

            LinearDimension linedim4 = new LinearDimension(new Line(p1, p1p), offset, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim4, dcon);

            LinearDimension linedim5 = new LinearDimension(new Line(p1p, p3p), offset * 3, 180, dimensionStyle);
            fun.dxflinedim(dxf, linedim5, ls);

            LinearDimension linedim6 = new LinearDimension(new Line(p1p, p6p), offset * 4, 180, dimensionStyle);
            fun.dxflinedim(dxf, linedim6, oal);

            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }





            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void BridgeTool(Dictionary<string, Object> data)  //桥工具
        {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线

            double pi = Math.PI;

            //double bdx = 60.0; //Convert.ToDouble(data["bdx"]);
            //double lf = 15.0; //Convert.ToDouble(data["lf"]);
            //double lpr = 45.0; //Convert.ToDouble(data["lpr"]);
            //double oaw = 15.0; //Convert.ToDouble(data["oaw"]);

            //string path = "E:\\dxfp\\BridgeTool.dxf"; // Convert.ToString(data["path"]);

            double bdx = Convert.ToDouble(data["bdx"]);
            double lf = Convert.ToDouble(data["lf"]);
            double lpr = Convert.ToDouble(data["lpr"]);
            double oaw = Convert.ToDouble(data["oaw"]);

            string path = Convert.ToString(data["path"]);

            double ang1 = Math.Asin(oaw / bdx);

            Vector2 p0 = new Vector2(0, 0);
            Vector2 p0p = fun.Polar(p0, 0, bdx);
            Vector2 p1 = fun.Polar(p0p, 0.5 * pi, bdx / 2);
            Vector2 p2 = fun.Polar(p1, 0, lf);
            Vector2 p3 = fun.Polar(p0p, 0.5 * pi, 0.5 * bdx * Math.Cos(ang1));
            Vector2 p4 = fun.Polar(p3, 0, lf / 2);
            double dis1 = p1.Y - p3.Y;
            Vector2 p5 = fun.Polar(p4, 0.5 * pi, 0.7 * dis1);
            Vector2 p6 = fun.Polar(p2, 1.5 * pi, 0.6 * dis1);
            double ang2 = fun.CalAngle(p6, p5);
            Vector2 p5z = fun.Polar(p5, 1.5 * pi, 0.15);
            Vector2 p5y = fun.Polar(p5, ang2 - pi, 0.15);
            Vector2 p6z = fun.Polar(p6, ang2, 0.1);
            Vector2 p6y = fun.Polar(p6, 0.5 * pi, 0.1);
            Vector2 p7 = fun.Polar(p0p, pi / 2, bdx / 4);
            Vector2 p8 = fun.Polar(p7, 0, lf);
            Vector2 p9 = fun.Polar(p0p, pi / 2, bdx / 6);
            Vector2 p10 = fun.Polar(p9, 0, lf);
            Vector2 p11 = fun.Polar(p0p, 0.5 * pi, bdx / 24);
            Vector2 p12 = fun.Polar(p11, 0, lf);
            Vector2 p1p = new Vector2(p1.X, p0p.Y - p1.Y);
            Vector2 p2p = new Vector2(p2.X, p0p.Y - p2.Y);
            Vector2 p3p = new Vector2(p3.X, p0p.Y - p3.Y);
            Vector2 p4p = new Vector2(p4.X, p0p.Y - p4.Y);
            Vector2 p5zp = new Vector2(p5z.X, p0p.Y - p5z.Y);
            Vector2 p5yp = new Vector2(p5y.X, p0p.Y - p5y.Y);
            Vector2 p6zp = new Vector2(p6z.X, p0p.Y - p6z.Y);
            Vector2 p6yp = new Vector2(p6y.X, p0p.Y - p6y.Y);
            Vector2 p7p = new Vector2(p7.X, p0p.Y - p7.Y);
            Vector2 p8p = new Vector2(p8.X, p0p.Y - p8.Y);
            Vector2 p9p = new Vector2(p9.X, p0p.Y - p9.Y);
            Vector2 p10p = new Vector2(p10.X, p0p.Y - p10.Y);
            Vector2 p11p = new Vector2(p11.X, p0p.Y - p11.Y);
            Vector2 p12p = new Vector2(p12.X, p0p.Y - p12.Y);

            Arc arc1 = fun.DrawArc(fun.Polar(p0, 0, bdx / 2), p0, fun.Polar(p0, pi / 2, bdx / 2));

            Vector2 p16 = fun.Polar(p0, pi / 2 - ang1, bdx / 2);
            Vector2 p17 = new Vector2(p0.X - p16.X, p16.Y);
            Vector2 p18 = new Vector2(p17.X, p0.Y - p17.Y);
            Vector2 p19 = new Vector2(p16.X, p0.Y - p16.Y);
            Vector2 p20 = fun.getPointForArcandLine(p6, fun.Polar(p6, pi, 100), p0, arc1);
            Vector2 p21 = new Vector2(p0.X - p20.X, p20.Y);
            Vector2 p22 = new Vector2(p21.X, p0.Y - p21.Y);
            Vector2 p23 = new Vector2(p20.X, p0.Y - p20.Y);

            LwPolyline poly1 = new LwPolyline();
            poly1.Vertexes.Add(new LwPolylineVertex(p6y));
            poly1.Vertexes.Add(new LwPolylineVertex(p2));
            poly1.Vertexes.Add(new LwPolylineVertex(p1));
            poly1.Vertexes.Add(new LwPolylineVertex(p1p));
            poly1.Vertexes.Add(new LwPolylineVertex(p2p));
            poly1.Vertexes.Add(new LwPolylineVertex(p6yp));
            fun.PolyFill(dxf, poly1, 0.1, contour);

            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p5y));
            poly2.Vertexes.Add(new LwPolylineVertex(p6z));
            poly2.Vertexes[1].Bulge = Math.Tan((1.5 * pi - ang2) / 4);
            poly2.Vertexes.Add(new LwPolylineVertex(p6y));
            poly2.Vertexes.Add(new LwPolylineVertex(p6yp));
            poly2.Vertexes[3].Bulge = Math.Tan((1.5 * pi - ang2) / 4);
            poly2.Vertexes.Add(new LwPolylineVertex(p6zp));
            poly2.Vertexes.Add(new LwPolylineVertex(p5yp));
            fun.PolyFill(dxf, poly2, 0.1, contour);

            LwPolyline poly3 = new LwPolyline();
            poly3.Vertexes.Add(new LwPolylineVertex(p5y));
            poly3.Vertexes[0].Bulge = Math.Tan((1.5 * pi - ang2) / 4);
            poly3.Vertexes.Add(new LwPolylineVertex(p5z));
            poly3.Vertexes.Add(new LwPolylineVertex(p5zp));
            poly3.Vertexes[2].Bulge = Math.Tan((1.5 * pi - ang2) / 4);
            poly3.Vertexes.Add(new LwPolylineVertex(p5yp));
            fun.PolyFill(dxf, poly3, 0.1, contour);

            Vector2[] line1 = { p3, p4 };
            fun.drawPlineOfw(dxf, line1, 0.1, contour);

            //Line line2 = new Line(p3p, p4p);
            //line2.Linetype = Linetype.Dashed;
            Vector2[] line2 = { p3p, p4p };
            fun.drawPlineOfw(dxf, line2, 0.1, contour);
            // dxf.AddEntity(line2);

            LwPolyline poly4 = new LwPolyline();
            poly4.Vertexes.Add(new LwPolylineVertex(p16));
            poly4.Vertexes[0].Bulge = Math.Tan(ang1 / 2);
            poly4.Vertexes.Add(new LwPolylineVertex(p17));
            poly4.Vertexes.Add(new LwPolylineVertex(p18));
            poly4.Vertexes[2].Bulge = Math.Tan(ang1 / 2);
            poly4.Vertexes.Add(new LwPolylineVertex(p19));
            poly4.Vertexes.Add(new LwPolylineVertex(p16));
            fun.PolyFill(dxf, poly4, 0.1, contour);

            Vector2[] line3 = { p20, p23 };
            fun.drawPlineOfw(dxf, line3, 0.1, contour);
            Vector2[] line4 = { p21, p22 };
            fun.drawPlineOfw(dxf, line4, 0.1, contour);

            Vector2[] cenline1 = { fun.Polar(p0, pi, 0.5 * oaw + 1), fun.Polar(p0, 0, 0.5 * oaw + 1) };
            fun.drawPlinetype(dxf, cenline1, 0.15, centre, Linetype.Center);
            Vector2[] cenline2 = { fun.Polar(p0, 0.5 * pi, 0.5 * bdx + 1), fun.Polar(p0, 1.5 * pi, 0.5 * bdx + 1) };
            fun.drawPlinetype(dxf, cenline2, 0.15, centre, Linetype.Center);
            Vector2[] cenline3 = { fun.Polar(p0p, pi, 1), fun.Polar(p0p, 0, lf + 1) };
            fun.drawPlinetype(dxf, cenline3, 0.15, centre, Linetype.Center);
            Vector2[] cenline4 = { new Vector2(p7.X - 1, (p7.Y + p9.Y) / 2), new Vector2(p8.X + 1, (p7.Y + p9.Y) / 2) };
            fun.drawPlinetype(dxf, cenline4, 0.15, centre, Linetype.Center);
            Vector2[] cenline5 = { new Vector2(p7.X - 1, (p7p.Y + p9p.Y) / 2), new Vector2(p8.X + 1, (p7p.Y + p9p.Y) / 2) };
            fun.drawPlinetype(dxf, cenline5, 0.15, centre, Linetype.Center);

            fun.drawcircle(dxf, p0, bdx / 24, 0.1, contour);
            fun.drawcircle(dxf, new Vector2(p0.X, (p7.Y + p9.Y) / 2), bdx / 24, 0.1, contour);
            fun.drawcircle(dxf, new Vector2(p0.X, (p7p.Y + p9p.Y) / 2), bdx / 24, 0.1, contour);

            Vector2[] xuline1 = { p7, p8 };
            fun.drawPlinetype(dxf, xuline1, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline2 = { p9, p10 };
            fun.drawPlinetype(dxf, xuline2, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline3 = { p11, p12 };
            fun.drawPlinetype(dxf, xuline3, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline4 = { p7p, p8p };
            fun.drawPlinetype(dxf, xuline4, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline5 = { p9p, p10p };
            fun.drawPlinetype(dxf, xuline5, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline6 = { p11p, p12p };
            fun.drawPlinetype(dxf, xuline6, 0.15, refin, Linetype.Dashed);

            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = 0.5;
            double offset = 7;

            LinearDimension linedim1 = new LinearDimension(new Line(p18, p19), offset, 180, dimensionStyle);
            fun.dxflinedim(dxf, linedim1, oaw);

            LinearDimension linedim2 = new LinearDimension(new Line(p1p, p2p), offset, 180, dimensionStyle);
            fun.dxflinedim(dxf, linedim2, lf);

            LinearDimension linedim3 = new LinearDimension(new Line(p2, p2p), offset, 270, dimensionStyle);
            fun.dxflinedim(dxf, linedim3, bdx);


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }



            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }

        public static void SlideForAdjustableUnits(Dictionary<string, Object> data)  //微调单元滑块
        {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线

            double pi = Math.PI;

            //double hf = 20.0; //Convert.ToDouble(data["hf"]);
            //double lscn = 40.0; //Convert.ToDouble(data["lscn"]);
            //double oah = 50.0; //Convert.ToDouble(data["oah"]);
            //double adjul = 45.0; //Convert.ToDouble(data["adju"]);
            //double dconws = 25.0; //Convert.ToDouble(data["dconws"]);
            //double oal = 80.0; //Convert.ToDouble(data["oal"]);
            //double oaw = 45.0; //Convert.ToDouble(data["oaw"]);

            //string path = "E:\\dxfp\\SlideForAdjustableUnits.dxf"; // Convert.ToString(data["path"]);  

            double hf = Convert.ToDouble(data["hf"]);
            double lscn = Convert.ToDouble(data["lscn"]);
            double oah = Convert.ToDouble(data["oah"]);
            double adjul = Convert.ToDouble(data["adju"]);
            double dconws = Convert.ToDouble(data["dconws"]);
            double oal = Convert.ToDouble(data["oal"]);
            double oaw = Convert.ToDouble(data["oaw"]);

            string path = Convert.ToString(data["path"]);

            Vector2 p00 = new Vector2(0, 0);
            Vector2 p01 = fun.Polar(p00, pi / 2, oal);
            Vector2 p1 = new Vector2(p01.X, p01.Y - 0.1 * lscn);
            Vector2 p2 = new Vector2(p00.X - 0.1 * (oah - dconws), p00.Y);
            Vector2 p3 = new Vector2(p2.X - dconws / 2, p2.Y);
            Vector2 p4 = new Vector2(p3.X - dconws / 2, p3.Y);
            Vector2 p5 = new Vector2(p4.X - 0.3 * (oah - dconws), p4.Y);
            Vector2 p6 = new Vector2(p00.X - oah, p00.Y);
            Vector2 p7 = new Vector2(p6.X, p01.Y - 0.2 * lscn);
            Vector2 p8 = new Vector2(p7.X, p01.Y - 0.05 * lscn);
            Vector2 p9 = new Vector2(p5.X, p01.Y - 0.1 * lscn);
            Vector2 p10 = new Vector2(p9.X, p01.Y);
            Vector2 p11 = new Vector2(p4.X, p10.Y);
            Vector2 p12 = new Vector2(p3.X, p01.Y);
            Vector2 p13 = new Vector2(p2.X, p01.Y);
            Vector2 p14 = new Vector2((p3.X + p4.X) / 2, p7.Y);
            Vector2 p144 = new Vector2(p14.X, p00.Y);
            Vector2 p15 = new Vector2(p00.X + dconws / 2, p00.Y);
            Vector2 p16 = new Vector2(p15.X + (oaw - dconws) / 2, p15.Y);
            Vector2 p17 = new Vector2(p15.X + oaw / 2, p16.Y);
            Vector2 p18 = new Vector2(p17.X + dconws / 2, p17.Y);
            Vector2 p19 = new Vector2(p15.X + oaw, p15.Y);
            Vector2 p20 = new Vector2(p19.X, p7.Y);
            Vector2 p24 = new Vector2(p15.X, p20.Y);
            Vector2 p25 = new Vector2(p17.X, p20.Y - oaw * 0.5 / Math.Tan(40.0 * pi / 180));
            Vector2 p31 = new Vector2((p5.X + p6.X) / 2, p01.Y - lscn);
            Vector2 p30 = new Vector2(p31.X, p31.Y + lscn / 2);
            Vector2 p32 = new Vector2(p31.X, p31.Y - lscn / 2);

            Arc arc2 = fun.DrawArc(p20, p25, p24);
            Vector2 p23 = fun.getPointForArcandLine(p1, fun.Polar(p1, 0, 100), p25, arc2);
            Vector2 p21 = new Vector2(p17.X - p23.X + p17.X, p23.Y);
            Vector2 p26 = new Vector2(p23.X, p17.Y);
            Vector2 p27 = new Vector2(p21.X, p17.Y);
            Vector2 p33 = new Vector2(p01.X, p01.Y - adjul);

            Vector2[] dotline1 = { fun.Polar(p12, pi / 2, 4), fun.Polar(p3, 1.5 * pi, 4) };
            fun.drawPlinetype(dxf, dotline1, 0.15, centre, Linetype.Center); //dxf文件 线段名字 颜色 线形
            Vector2[] dotline2 = { fun.Polar(p17, pi / 2, oal + 4), fun.Polar(p17, 1.5 * pi, 4) };
            fun.drawPlinetype(dxf, dotline2, 0.15, centre, Linetype.Center); //dxf文件 线段名字 颜色 线形

            LwPolyline poly = new LwPolyline();
            poly.Vertexes.Add(new LwPolylineVertex(p01));
            poly.Vertexes.Add(new LwPolylineVertex(p1));
            poly.Vertexes.Add(new LwPolylineVertex(p00));
            poly.Vertexes.Add(new LwPolylineVertex(p2));
            poly.Vertexes.Add(new LwPolylineVertex(p3));
            poly.Vertexes.Add(new LwPolylineVertex(p4));
            poly.Vertexes.Add(new LwPolylineVertex(p5));
            poly.Vertexes.Add(new LwPolylineVertex(p6));
            poly.Vertexes.Add(new LwPolylineVertex(p7));
            poly.Vertexes.Add(new LwPolylineVertex(p8));
            poly.Vertexes.Add(new LwPolylineVertex(p9));
            poly.Vertexes.Add(new LwPolylineVertex(p10));
            poly.Vertexes.Add(new LwPolylineVertex(p11));
            poly.Vertexes[12].Bulge = Math.Tan(pi / 14);
            poly.Vertexes.Add(new LwPolylineVertex(p13));
            poly.Vertexes.Add(new LwPolylineVertex(p01));
            fun.PolyFill(dxf, poly, 0.3, contour);

            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p15));
            poly2.Vertexes.Add(new LwPolylineVertex(p16));
            poly2.Vertexes.Add(new LwPolylineVertex(p17));
            poly2.Vertexes.Add(new LwPolylineVertex(p18));
            poly2.Vertexes.Add(new LwPolylineVertex(p19));
            poly2.Vertexes.Add(new LwPolylineVertex(p20));
            poly2.Vertexes[5].Bulge = Math.Tan(pi / 9);
            poly2.Vertexes.Add(new LwPolylineVertex(p24));
            poly2.Vertexes.Add(new LwPolylineVertex(p15));
            fun.PolyFill(dxf, poly2, 0.3, contour);

            Vector2[] xuline1 = { p13, p2 };
            fun.drawPlinetype(dxf, xuline1, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline2 = { p11, p4 };
            fun.drawPlinetype(dxf, xuline2, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline3 = { p5, p9 };
            fun.drawPlinetype(dxf, xuline3, 0.15, refin, Linetype.Dashed);

            fun.drawcircle(dxf, p31, 0.1 * lscn, 0.3, contour);
            fun.drawcircle(dxf, p30, 0.1 * lscn, 0.3, contour);
            fun.drawcircle(dxf, p32, 0.1 * lscn, 0.3, contour);

            Vector2[] xiline1 = { p26, p23 };
            fun.drawPlineOfw(dxf, xiline1, 0.3, contour);
            Vector2[] xiline2 = { p27, p21 };
            fun.drawPlineOfw(dxf, xiline2, 0.3, contour);
            Vector2[] xiline3 = { p14, p144 };
            fun.drawPlineOfw(dxf, xiline3, 0.3, contour);
            Vector2[] xiline4 = { p1, p14, p7 };
            fun.drawPlineOfw(dxf, xiline4, 0.3, contour);

            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = 0.5;
            double offset = 7;

            LinearDimension linedim1 = new LinearDimension(new Line(p10, p31), offset * 2, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim1, lscn);

            LinearDimension linedim2 = new LinearDimension(new Line(p6, p00), offset * 2, 180, dimensionStyle);
            fun.dxflinedim(dxf, linedim2, oah);

            LinearDimension linedim3 = new LinearDimension(new Line(p4, p2), offset, 180, dimensionStyle);
            fun.dxflinedim(dxf, linedim3, dconws);

            LinearDimension linedim4 = new LinearDimension(new Line(p10, p12), offset, 0, dimensionStyle);
            fun.dxflinedim(dxf, linedim4, hf);

            LinearDimension linedim5 = new LinearDimension(new Line(p33, p01), offset, 270, dimensionStyle);
            fun.dxflinedim(dxf, linedim5, adjul);

            LinearDimension linedim6 = new LinearDimension(new Line(p00, p01), offset * 2, 270, dimensionStyle);
            fun.dxflinedim(dxf, linedim6, oal);

            LinearDimension linedim7 = new LinearDimension(new Line(p15, p19), offset, 180, dimensionStyle);
            fun.dxflinedim(dxf, linedim7, oaw);


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            Vector2 p0 = new Vector2(0, 0);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }


            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);

        }

        public static void SlideElement(Dictionary<string, Object> data)  //滑动元件  
        {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线

            double pi = Math.PI;

            //double hf = 18.0; //Convert.ToDouble(data["hf"]);
            //double lscn = 55.0; //Convert.ToDouble(data["lscn"]);
            //double oah = 45.0; //Convert.ToDouble(data["oah"]);
            //double adjul = 25.0; //Convert.ToDouble(data["adjul"]);
            //double hsup = 35.0; //Convert.ToDouble(data["hsup"]);
            //double oal = 80.0; //Convert.ToDouble(data["oal"]);
            //double lpr = 35.0; //Convert.ToDouble(data["lpr"]);
            //double oaw = 35.0; //Convert.ToDouble(data["oaw"]);

            //string path = "E:\\dxfp\\SlideElement.dxf"; // Convert.ToString(data["path"]);    

            double hf = Convert.ToDouble(data["hf"]);
            double lscn = Convert.ToDouble(data["lscn"]);
            double oah = Convert.ToDouble(data["oah"]);
            double adjul = Convert.ToDouble(data["adjul"]);
            double hsup = Convert.ToDouble(data["hsup"]);
            double oal = Convert.ToDouble(data["oal"]);
            double lpr = Convert.ToDouble(data["lpr"]);
            double oaw = Convert.ToDouble(data["oaw"]);

            string path = Convert.ToString(data["path"]); 

            Vector2 p00 = new Vector2(0, 0);
            Vector2 p01 = fun.Polar(p00, pi / 2, oal);
            Vector2 p1 = new Vector2(p01.X, p01.Y - 0.02 * oal);
            Vector2 p2 = new Vector2(p1.X, p01.Y - 0.06 * oal);
            Vector2 p3 = new Vector2(p00.X, p00.Y);
            Vector2 p4 = new Vector2(p3.X - oah, p3.Y);
            Vector2 p5 = new Vector2(p4.X, p2.Y);
            Vector2 p6 = new Vector2(p5.X, p01.Y - 0.04 * oal);
            Vector2 p7 = new Vector2(p4.X + (hsup - hf), p6.Y);
            Vector2 p8 = new Vector2(p7.X, p01.Y);
            Vector2 p9 = new Vector2(p8.X + hf, p8.Y);
            Vector2 p10 = new Vector2(p9.X, p7.Y);
            Vector2 p11 = new Vector2(p4.X + (hsup - hf) / 2, p4.Y + lscn);
            Vector2 p12 = new Vector2(p11.X, p11.Y - 0.3 * lscn);
            Vector2 p13 = new Vector2(p12.X, p12.Y - 0.3 * lscn);
            Vector2 p14 = new Vector2(p7.X, p3.Y);
            Vector2 p15 = new Vector2(p9.X, p14.Y);
            Vector2 p17 = new Vector2(p15.X, p15.Y + adjul);
            Vector2 p16 = new Vector2(p17.X, p17.Y - adjul * 0.3);
            Vector2 p18 = new Vector2(p17.X, p17.Y + adjul * 0.3);
            Vector2 p20 = new Vector2(p15.X, p2.Y - adjul);
            Vector2 p19 = new Vector2(p17.X, p20.Y - adjul * 0.3);
            Vector2 p21 = new Vector2(p17.X, p20.Y + adjul * 0.3);
            Vector2 p22 = new Vector2(p14.X, p21.Y);
            Vector2 p23 = new Vector2(p22.X, p20.Y);
            Vector2 p24 = new Vector2(p14.X, p19.Y);
            Vector2 p25 = new Vector2(p24.X, p18.Y);
            Vector2 p26 = new Vector2(p25.X, p17.Y);
            Vector2 p27 = new Vector2(p26.X, p16.Y);
            Vector2 p28 = new Vector2(p3.X + oaw, p2.Y);
            Vector2 p29 = new Vector2(p28.X, p3.Y);
            Vector2 p34 = new Vector2(p29.X + oaw, p29.Y);
            Vector2 p35 = new Vector2(p34.X, p28.Y);
            Vector2 p40 = new Vector2(p29.X + oaw / 2, p20.Y);
            Vector2 p41 = new Vector2(p40.X, p17.Y);
            Vector2 p42 = new Vector2(p41.X, p3.Y);
            Vector2 p400 = new Vector2(p40.X, p28.Y - 0.5 * oaw / Math.Tan(30.0 / 180 * pi));
            Vector2 p401 = new Vector2(p400.X, p400.Y + 0.5 * oaw / Math.Sin(30.0 / 180 * pi));
            Arc arc1 = fun.DrawArc(p401, p400, p28);
            Vector2 p39 = fun.getPointForArcandLine(p7, fun.Polar(p7, 0, 100), p400, arc1);
            Vector2 p38 = fun.getPointForArcandLine(p1, fun.Polar(p1, 0, 100), p400, arc1);

            // Vector2 p39 = new Vector2(p29.X + 3, p7.Y);
            // Vector2 p38 = new Vector2(p29.X + 6, p1.Y);
            Vector2 p37 = new Vector2(p42.X - p38.X + p42.X, p38.Y);
            Vector2 p36 = new Vector2(p42.X - p39.X + p42.X, p39.Y);
            Vector2 p30 = new Vector2(p39.X, p29.Y);
            Vector2 p31 = new Vector2(p38.X, p30.Y);
            Vector2 p32 = new Vector2(p37.X, p31.Y);
            Vector2 p33 = new Vector2(p36.X, p32.Y);
            Vector2 p44 = new Vector2(p29.X, p29.Y - oaw);
            Vector2 p45 = new Vector2(p44.X, p44.Y - oah);
            Vector2 p46 = new Vector2(p30.X, p45.Y);
            Vector2 p47 = new Vector2(p46.X, p46.Y + hsup - hf);
            Vector2 p49 = new Vector2(p41.X, p47.Y);
            Vector2 p48 = new Vector2(p49.X - adjul * 0.3, p49.Y);
            Vector2 p50 = new Vector2(p49.X + adjul * 0.3, p49.Y);
            Vector2 p51 = new Vector2(p33.X, p50.Y);
            Vector2 p53 = new Vector2(p51.X, p51.Y - ((hsup - hf) / 2));
            Vector2 p52 = new Vector2(p53.X, p53.Y + 0.1 * lscn);
            Vector2 p54 = new Vector2(p53.X, p53.Y - 0.1 * lscn);
            Vector2 p55 = new Vector2(p54.X, p46.Y);
            Vector2 p56 = new Vector2(p34.X, p55.Y);
            Vector2 p57 = new Vector2(p56.X, p54.Y);
            Vector2 p58 = new Vector2(p57.X, p53.Y);
            Vector2 p59 = new Vector2(p58.X, p52.Y);
            Vector2 p60 = new Vector2(p59.X, p44.Y);
            Vector2 p61 = new Vector2(p32.X, p60.Y);
            Vector2 p62 = new Vector2(p32.X, p45.Y + hsup);
            Vector2 p63 = new Vector2(p50.X, p62.Y);
            Vector2 p64 = new Vector2(p49.X, p62.Y);
            Vector2 p65 = new Vector2(p48.X, p62.Y);
            Vector2 p66 = new Vector2(p31.X, p62.Y);
            Vector2 p67 = new Vector2(p66.X, p61.Y);

            Vector2[] dotline1 = { fun.Polar(p42, pi * 1.5, 4), fun.Polar(p42, 0.5 * pi, oal + 4) };
            fun.drawPlinetype(dxf, dotline1, 0.15, centre, Linetype.Center); //dxf文件 线段名字 颜色 线形
            Vector2[] dotline2 = { fun.Polar(p41, pi / 2, 0.4 * adjul), fun.Polar(p41, 1.5 * pi, 0.4 * adjul) };
            fun.drawPlinetype(dxf, dotline2, 0.15, centre, Linetype.Center);
            Vector2[] dotline3 = { fun.Polar(p41, 0, 0.4 * adjul), fun.Polar(p41, pi, 0.4 * adjul) };
            fun.drawPlinetype(dxf, dotline3, 0.15, centre, Linetype.Center);
            Vector2[] dotline4 = { fun.Polar(p40, pi / 2, 0.4 * adjul), fun.Polar(p40, 1.5 * pi, 0.4 * adjul) };
            fun.drawPlinetype(dxf, dotline4, 0.15, centre, Linetype.Center);
            Vector2[] dotline5 = { fun.Polar(p40, 0, 0.4 * adjul), fun.Polar(p40, pi, 0.4 * adjul) };
            fun.drawPlinetype(dxf, dotline5, 0.15, centre, Linetype.Center);
            Vector2[] dotline6 = { fun.Polar(p11, pi / 2, 0.13 * lscn), fun.Polar(p11, 1.5 * pi, 0.13 * lscn) };
            fun.drawPlinetype(dxf, dotline6, 0.15, centre, Linetype.Center);
            Vector2[] dotline7 = { fun.Polar(p11, pi, 0.13 * lscn), fun.Polar(p11, 0 * pi, 0.13 * lscn) };
            fun.drawPlinetype(dxf, dotline7, 0.15, centre, Linetype.Center);
            Vector2[] dotline8 = { fun.Polar(p12, pi / 2, 0.13 * lscn), fun.Polar(p12, 1.5 * pi, 0.13 * lscn) };
            fun.drawPlinetype(dxf, dotline8, 0.15, centre, Linetype.Center);
            Vector2[] dotline9 = { fun.Polar(p12, pi, 0.13 * lscn), fun.Polar(p12, 0 * pi, 0.13 * lscn) };
            fun.drawPlinetype(dxf, dotline9, 0.15, centre, Linetype.Center);
            Vector2[] dotline10 = { fun.Polar(p13, pi / 2, 0.13 * lscn), fun.Polar(p13, 1.5 * pi, 0.13 * lscn) };
            fun.drawPlinetype(dxf, dotline10, 0.15, centre, Linetype.Center);
            Vector2[] dotline11 = { fun.Polar(p13, pi, 0.13 * lscn), fun.Polar(p13, 0 * pi, 0.13 * lscn) };
            fun.drawPlinetype(dxf, dotline11, 0.15, centre, Linetype.Center);
            Vector2[] dotline12 = { fun.Polar(p23, pi, 2), fun.Polar(p20, 0 * pi, 2) };
            fun.drawPlinetype(dxf, dotline12, 0.15, centre, Linetype.Center);
            Vector2[] dotline13 = { fun.Polar(p26, pi, 2), fun.Polar(p17, 0 * pi, 2) };
            fun.drawPlinetype(dxf, dotline13, 0.15, centre, Linetype.Center);
            Vector2[] dotline14 = { fun.Polar(p64, pi / 2, 4), fun.Polar(p49, 1.5 * pi, 4) };
            fun.drawPlinetype(dxf, dotline14, 0.15, centre, Linetype.Center);
            Vector2[] dotline15 = { fun.Polar(p53, pi, 2), fun.Polar(p58, 0 * pi, 2) };
            fun.drawPlinetype(dxf, dotline15, 0.15, centre, Linetype.Center);

            Vector2[] xuline1 = { p22, p21 };
            fun.drawPlinetype(dxf, xuline1, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline2 = { p19, p24 };
            fun.drawPlinetype(dxf, xuline2, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline3 = { p25, p18 };
            fun.drawPlinetype(dxf, xuline3, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline4 = { p27, p16 };
            fun.drawPlinetype(dxf, xuline4, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline5 = { p38, p31 };
            fun.drawPlinetype(dxf, xuline5, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline6 = { p37, p32 };
            fun.drawPlinetype(dxf, xuline6, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline7 = { p65, p48 };
            fun.drawPlinetype(dxf, xuline7, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline8 = { p63, p50 };
            fun.drawPlinetype(dxf, xuline8, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline9 = { p52, p59 };
            fun.drawPlinetype(dxf, xuline9, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline10 = { p54, p57 };
            fun.drawPlinetype(dxf, xuline10, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline11 = { p14, p7 };
            fun.drawPlinetype(dxf, xuline11, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline12 = { p10, p15 };
            fun.drawPlinetype(dxf, xuline12, 0.15, refin, Linetype.Dashed);

            LwPolyline poly = new LwPolyline();
            poly.Vertexes.Add(new LwPolylineVertex(p10));
            poly.Vertexes.Add(new LwPolylineVertex(p1));
            poly.Vertexes.Add(new LwPolylineVertex(p2));
            poly.Vertexes.Add(new LwPolylineVertex(p3));
            poly.Vertexes.Add(new LwPolylineVertex(p4));
            poly.Vertexes.Add(new LwPolylineVertex(p5));
            poly.Vertexes.Add(new LwPolylineVertex(p6));
            poly.Vertexes.Add(new LwPolylineVertex(p7));
            poly.Vertexes.Add(new LwPolylineVertex(p8));
            poly.Vertexes.Add(new LwPolylineVertex(p9));
            poly.Vertexes.Add(new LwPolylineVertex(p10));
            fun.PolyFill(dxf, poly, 0.3, contour);

            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p29));
            poly2.Vertexes.Add(new LwPolylineVertex(p30));
            poly2.Vertexes.Add(new LwPolylineVertex(p31));
            poly2.Vertexes.Add(new LwPolylineVertex(p34));
            poly2.Vertexes.Add(new LwPolylineVertex(p35));
            poly2.Vertexes[4].Bulge = Math.Tan(pi / 12);
            poly2.Vertexes.Add(new LwPolylineVertex(p28));
            poly2.Vertexes.Add(new LwPolylineVertex(p29));
            fun.PolyFill(dxf, poly2, 0.3, contour);


            LwPolyline poly3 = new LwPolyline();
            poly3.Vertexes.Add(new LwPolylineVertex(p44));
            poly3.Vertexes.Add(new LwPolylineVertex(p45));
            poly3.Vertexes.Add(new LwPolylineVertex(p46));
            poly3.Vertexes.Add(new LwPolylineVertex(p47));
            poly3.Vertexes.Add(new LwPolylineVertex(p48));
            poly3.Vertexes.Add(new LwPolylineVertex(p51));
            poly3.Vertexes.Add(new LwPolylineVertex(p55));
            poly3.Vertexes.Add(new LwPolylineVertex(p56));
            poly3.Vertexes.Add(new LwPolylineVertex(p60));
            poly3.Vertexes.Add(new LwPolylineVertex(p61));
            poly3.Vertexes.Add(new LwPolylineVertex(p62));
            poly3.Vertexes.Add(new LwPolylineVertex(p66));
            poly3.Vertexes.Add(new LwPolylineVertex(p67));
            poly3.Vertexes.Add(new LwPolylineVertex(p44));
            fun.PolyFill(dxf, poly3, 0.3, contour);

            fun.drawcircle(dxf, p11, 0.1 * lscn, 0.3, contour);
            fun.drawcircle(dxf, p12, 0.1 * lscn, 0.3, contour);
            fun.drawcircle(dxf, p13, 0.1 * lscn, 0.3, contour);
            fun.drawcircle(dxf, p40, 0.3 * adjul, 0.3, contour);
            fun.drawcircle(dxf, p41, 0.3 * adjul, 0.3, contour);

            Vector2[] xiline1 = { p39, p30 };
            fun.drawPlineOfw(dxf, xiline1, 0.3, contour);
            Vector2[] xiline2 = { p36, p33 };
            fun.drawPlineOfw(dxf, xiline2, 0.3, contour);
            Vector2[] xiline3 = { p5, p2 };
            fun.drawPlineOfw(dxf, xiline3, 0.3, contour);

            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = 0.5;
            double offset = 7;


            LinearDimension linedim1 = new LinearDimension(new Line(p4, p11), offset * 2, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim1, lscn);

            LinearDimension linedim2 = new LinearDimension(new Line(p14, p15), offset * 1, 180, dimensionStyle);
            fun.dxflinedim(dxf, linedim2, oah);

            LinearDimension linedim3 = new LinearDimension(new Line(p7, p1), offset * 2, 0, dimensionStyle);
            fun.dxflinedim(dxf, linedim3, lpr);

            LinearDimension linedim4 = new LinearDimension(new Line(p51, p62), offset * 2, 270, dimensionStyle);
            fun.dxflinedim(dxf, linedim4, hf);

            LinearDimension linedim5 = new LinearDimension(new Line(p42, p41), offset * 3, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim5, adjul);

            LinearDimension linedim6 = new LinearDimension(new Line(p66, p45), offset * 2, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim6, hsup);

            LinearDimension linedim7 = new LinearDimension(new Line(p34, p30), offset, 180, dimensionStyle);
            fun.dxflinedim(dxf, linedim7, oaw);

            LinearDimension linedim8 = new LinearDimension(new Line(p3, p9), offset * 2, 270, dimensionStyle);
            fun.dxflinedim(dxf, linedim8, oal);

            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            Vector2 p0 = new Vector2(0, 0);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }



            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);

        }

        public static void BalanceWeight(Dictionary<string, Object> data)  //平衡器 
        {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线

            double pi = Math.PI;

            //double hf = 18.0; //Convert.ToDouble(data["hf"]);
            //double lsc = 55.0; //Convert.ToDouble(data["lsc"]);
            //double oah = 45.0; //Convert.ToDouble(data["oah"]);
            //double hsup = 30.0; //Convert.ToDouble(data["hsup"]);
            //double oal = 80.0; //Convert.ToDouble(data["oal"]);
            //double oaw = 45.0; //Convert.ToDouble(data["oaw"]);
            //double r1, r2;
            //string path = "E:\\dxfp\\BalanceWeight.dxf"; // Convert.ToString(data["path"]);

            double hf = Convert.ToDouble(data["hf"]);
            double lsc = Convert.ToDouble(data["lsc"]);
            double oah = Convert.ToDouble(data["oah"]);
            double hsup = Convert.ToDouble(data["hsup"]);
            double oal = Convert.ToDouble(data["oal"]);
            double oaw = Convert.ToDouble(data["oaw"]);
            double r1, r2;
            string path = Convert.ToString(data["path"]);

            Vector2 p00 = new Vector2(0, 0);
            Vector2 p01 = fun.Polar(p00, pi / 2, oal);
            Vector2 p1 = new Vector2(p01.X, p01.Y - 0.15 * oal);
            Vector2 p2 = new Vector2(p1.X, p00.Y + lsc);
            Vector2 p3 = new Vector2(p00.X, p00.Y + oal - lsc);
            Vector2 p4 = new Vector2(p00.X, p00.Y + (p01.Y - p1.Y));
            Vector2 p5 = new Vector2(p00.X - (oah - hsup), p00.Y);
            Vector2 p6 = new Vector2(p5.X - hf, p00.Y);
            Vector2 p7 = new Vector2(p00.X - oah, p6.Y);
            Vector2 p8 = new Vector2(p7.X, p1.Y);
            Vector2 p9 = new Vector2(p8.X, p1.Y + 0.09 * oah);
            Vector2 p10 = new Vector2(p6.X, p9.Y);
            Vector2 p11 = new Vector2(p10.X, p01.Y);
            Vector2 p12 = new Vector2(p11.X, p8.Y);
            Vector2 p13 = new Vector2(p5.X, p12.Y);
            r1 = p1.Y - p2.Y;
            Vector2 p14 = new Vector2(p13.X, p13.Y - r1 * 0.4);
            Vector2 p15 = new Vector2(p12.X, p14.Y);
            Vector2 p16 = new Vector2(p15.X, p2.Y);
            Vector2 p17 = new Vector2(p16.X, p3.Y);
            r2 = p15.Y - p16.Y;
            Vector2 p18 = new Vector2(p17.X, p17.Y - r2);
            Vector2 p19 = new Vector2(p14.X, p18.Y);
            Vector2 p20 = new Vector2(p19.X, p4.Y);
            Vector2 p21 = new Vector2(p00.X + oaw, p00.Y);
            Vector2 p23 = new Vector2(p21.X + oaw / 2, p21.Y);
            Vector2 p25 = new Vector2(p21.X + oaw, p23.Y);
            Vector2 p26 = new Vector2(p25.X, p1.Y);
            Vector2 p29 = new Vector2(p21.X, p1.Y);
            Vector2 p200 = new Vector2(p23.X, p26.Y - 0.5 * oaw / Math.Tan(60.0 / 180 * pi));
            Vector2 p201 = new Vector2(p200.X, p200.Y + 0.5 * oaw / Math.Sin(60.0 / 180 * pi));
            Arc arc1 = fun.DrawArc(p201, p200, p29);
            Vector2 p28 = fun.getPointForArcandLine(p10, fun.Polar(p10, 0, 100), p200, arc1);
            Vector2 p22 = new Vector2(p28.X, p21.Y);
            Vector2 p24 = new Vector2(p23.X + (p23.X - p22.X), p22.Y);
            Vector2 p27 = new Vector2(p24.X, p28.Y);
            Vector2 p34 = new Vector2(p23.X + r2, p3.Y);
            Vector2 p35 = new Vector2(p23.X + r1, p34.Y);
            Vector2 p33 = new Vector2(p23.X - r2, p3.Y);
            Vector2 p32 = new Vector2(p23.X - r1, p34.Y);
            Vector2 p36 = new Vector2(p35.X, p2.Y);
            Vector2 p37 = new Vector2(p34.X, p2.Y);
            Vector2 p38 = new Vector2(p23.X, p37.Y);
            Vector2 p39 = new Vector2(p23.X, p34.Y);
            Vector2 p31 = new Vector2(p33.X, p38.Y);
            Vector2 p30 = new Vector2(p32.X, p31.Y);
            Vector2 p40 = new Vector2(p00.X, p00.Y - oaw);
            Vector2 p42 = new Vector2(p40.X, p40.Y - oaw / 2);
            Vector2 p41 = new Vector2(p42.X, p42.Y + r1);
            Vector2 p43 = new Vector2(p42.X, p42.Y - r1);
            Vector2 p44 = new Vector2(p42.X, p40.Y - oaw);
            Vector2 p45 = new Vector2(p44.X - oah, p44.Y);
            Vector2 p46 = new Vector2(p45.X, p45.Y + (p22.X - p21.X));
            Vector2 p47 = new Vector2(p6.X, p46.Y);
            Vector2 p56 = new Vector2(p47.X, p42.Y);
            Vector2 p49 = new Vector2(p56.X, p56.Y + r2);
            Vector2 p48 = new Vector2(p49.X, p56.Y - r2);
            Vector2 p50 = new Vector2(p49.X, p40.Y - (p22.X - p21.X));
            Vector2 p51 = new Vector2(p46.X, p50.Y);
            Vector2 p52 = new Vector2(p51.X, p51.Y + (p22.X - p21.X));
            Vector2 p53 = new Vector2(p5.X, p41.Y);
            Vector2 p54 = new Vector2(p53.X, p49.Y);
            Vector2 p55 = new Vector2(p54.X, p48.Y);
            Vector2 p57 = new Vector2(p53.X, p43.Y);

            Vector2[] dotline1 = { fun.Polar(p16, pi * 1.0, 4), fun.Polar(p2, 0.0 * pi, 4) };
            fun.drawPlinetype(dxf, dotline1, 0.15, centre, Linetype.Center); //dxf文件 线段名字 颜色 线形
            Vector2[] dotline2 = { fun.Polar(p17, pi * 1.0, 4), fun.Polar(p3, 0 * pi, 4) };
            fun.drawPlinetype(dxf, dotline2, 0.15, centre, Linetype.Center);
            Vector2[] dotline3 = { fun.Polar(p23, 1.5 * pi, 4), fun.Polar(p23, 0.5 * pi, 4 + oal) };
            fun.drawPlinetype(dxf, dotline3, 0.15, centre, Linetype.Center);
            Vector2[] dotline4 = { fun.Polar(p32, pi, 4), fun.Polar(p35, 0 * pi, 4) };
            fun.drawPlinetype(dxf, dotline4, 0.15, centre, Linetype.Center);
            Vector2[] dotline5 = { fun.Polar(p36, 0, 4), fun.Polar(p30, pi, 4) };
            fun.drawPlinetype(dxf, dotline5, 0.15, centre, Linetype.Center);
            Vector2[] dotline6 = { fun.Polar(p56, 1 * pi, 4), fun.Polar(p42, 0 * pi, 4) };
            fun.drawPlinetype(dxf, dotline6, 0.15, centre, Linetype.Center);

            Vector2[] xuline1 = { p14, p15 };
            fun.drawPlinetype(dxf, xuline1, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline2 = { p19, p18 };
            fun.drawPlinetype(dxf, xuline2, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline3 = { p20, p4 };
            fun.drawPlinetype(dxf, xuline3, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline4 = { p28, p22 };
            fun.drawPlinetype(dxf, xuline4, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline5 = { p24, p27 };
            fun.drawPlinetype(dxf, xuline5, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline6 = { p12, p6 };
            fun.drawPlinetype(dxf, xuline6, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline7 = { p5, p13 };
            fun.drawPlinetype(dxf, xuline7, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline8 = { p41, p53, p57, p43 };
            fun.drawPlinetype(dxf, xuline8, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline9 = { p54, p49 };
            fun.drawPlinetype(dxf, xuline9, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline10 = { p55, p48 };
            fun.drawPlinetype(dxf, xuline10, 0.15, refin, Linetype.Dashed);

            LwPolyline poly = new LwPolyline();
            poly.Vertexes.Add(new LwPolylineVertex(p01));
            poly.Vertexes.Add(new LwPolylineVertex(p1));
            poly.Vertexes.Add(new LwPolylineVertex(p2));
            poly.Vertexes.Add(new LwPolylineVertex(p3));
            poly.Vertexes.Add(new LwPolylineVertex(p00));
            poly.Vertexes.Add(new LwPolylineVertex(p5));
            poly.Vertexes.Add(new LwPolylineVertex(p6));
            poly.Vertexes.Add(new LwPolylineVertex(p7));
            poly.Vertexes.Add(new LwPolylineVertex(p8));
            poly.Vertexes.Add(new LwPolylineVertex(p9));
            poly.Vertexes.Add(new LwPolylineVertex(p10));
            poly.Vertexes.Add(new LwPolylineVertex(p11));
            poly.Vertexes.Add(new LwPolylineVertex(p01));
            fun.PolyFill(dxf, poly, 0.3, contour);

            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(p21));
            poly2.Vertexes.Add(new LwPolylineVertex(p25));
            poly2.Vertexes.Add(new LwPolylineVertex(p26));
            poly2.Vertexes[2].Bulge = Math.Tan(pi / 6);
            poly2.Vertexes.Add(new LwPolylineVertex(p29));
            poly2.Vertexes.Add(new LwPolylineVertex(p21));
            fun.PolyFill(dxf, poly2, 0.3, contour);


            LwPolyline poly3 = new LwPolyline();
            poly3.Vertexes.Add(new LwPolylineVertex(p40));
            poly3.Vertexes.Add(new LwPolylineVertex(p44));
            poly3.Vertexes.Add(new LwPolylineVertex(p45));
            poly3.Vertexes.Add(new LwPolylineVertex(p46));
            poly3.Vertexes.Add(new LwPolylineVertex(p47));
            poly3.Vertexes.Add(new LwPolylineVertex(p50));
            poly3.Vertexes.Add(new LwPolylineVertex(p51));
            poly3.Vertexes.Add(new LwPolylineVertex(p52));
            poly3.Vertexes.Add(new LwPolylineVertex(p40));
            fun.PolyFill(dxf, poly3, 0.3, contour);

            LwPolyline poly4 = new LwPolyline();
            poly4.Vertexes.Add(new LwPolylineVertex(p36));
            poly4.Vertexes[0].Bulge = Math.Tan(pi / 4);
            poly4.Vertexes.Add(new LwPolylineVertex(p30));
            poly4.Vertexes.Add(new LwPolylineVertex(p32));
            poly4.Vertexes[2].Bulge = Math.Tan(pi / 4);
            poly4.Vertexes.Add(new LwPolylineVertex(p35));
            poly4.Vertexes.Add(new LwPolylineVertex(p36));
            fun.PolyFill(dxf, poly4, 0.3, contour);

            LwPolyline poly5 = new LwPolyline();
            poly5.Vertexes.Add(new LwPolylineVertex(p37));
            poly5.Vertexes[0].Bulge = Math.Tan(pi / 4);
            poly5.Vertexes.Add(new LwPolylineVertex(p31));
            poly5.Vertexes.Add(new LwPolylineVertex(p33));
            poly5.Vertexes[2].Bulge = Math.Tan(pi / 4);
            poly5.Vertexes.Add(new LwPolylineVertex(p34));
            poly5.Vertexes.Add(new LwPolylineVertex(p37));
            fun.PolyFill(dxf, poly5, 0.3, contour);

            Vector2[] xiline1 = { p1, p8 };
            fun.drawPlineOfw(dxf, xiline1, 0.3, contour);

            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = 0.5;
            double offset = 7;

            LinearDimension linedim1 = new LinearDimension(new Line(p36, p25), offset * 2, 270, dimensionStyle);
            fun.dxflinedim(dxf, linedim1, lsc);

            LinearDimension linedim2 = new LinearDimension(new Line(p51, p40), offset * 1, 0, dimensionStyle);
            fun.dxflinedim(dxf, linedim2, oah);

            LinearDimension linedim3 = new LinearDimension(new Line(p24, p21), offset * 1, 180, dimensionStyle);
            fun.dxflinedim(dxf, linedim3, oaw);

            LinearDimension linedim4 = new LinearDimension(new Line(p5, p6), offset * 1, 180, dimensionStyle);
            fun.dxflinedim(dxf, linedim4, hf);

            LinearDimension linedim6 = new LinearDimension(new Line(p5, p7), offset * 2, 180, dimensionStyle);
            fun.dxflinedim(dxf, linedim6, hsup);

            LinearDimension linedim8 = new LinearDimension(new Line(p00, p01), offset * 1, 270, dimensionStyle);
            fun.dxflinedim(dxf, linedim8, oal);



            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            Vector2 p0 = new Vector2(0, 0);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }


            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);

        }

        public static void AdjustableUnit(Dictionary<string, Object> data)  //微调装置
        {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线

            double pi = Math.PI;

            //double lf = 20.0; //Convert.ToDouble(data["lf"]);
            //double lsc = 16.0; //Convert.ToDouble(data["lsc"]);
            //double lb = 40.0; //Convert.ToDouble(data["lb"]);
            //double bdx = 25.0; //Convert.ToDouble(data["bdx"]);
            //double oal = 50.0; //Convert.ToDouble(data["oal"]);

            //string path = "E:\\dxfp\\AdjustableUnit.dxf"; // Convert.ToString(data["path"]);

            double lf = Convert.ToDouble(data["lf"]);
            double lsc = Convert.ToDouble(data["lsc"]);
            double lb = Convert.ToDouble(data["lb"]);
            double bdx = Convert.ToDouble(data["bdx"]);
            double oal = Convert.ToDouble(data["oal"]);

            string path = Convert.ToString(data["path"]);

            Vector2 p00 = new Vector2(0, 0);
            Vector2 p01 = fun.Polar(p00, pi / 2, oal);
            Vector2 p1 = new Vector2(p01.X + 0.1 * bdx, p01.Y);
            Vector2 p2 = new Vector2(p1.X, p1.Y - 0.03 * oal);
            Vector2 p3 = new Vector2(p2.X + 0.15 * bdx, p2.Y);
            Vector2 p4 = new Vector2(p3.X, p3.Y - (lf - lsc));
            Vector2 p5 = new Vector2(p00.X + bdx / 2, p4.Y);
            Vector2 p6 = new Vector2(p5.X, p5.Y - lb);
            Vector2 p7 = new Vector2(p6.X - 0.1 * bdx / 2, p6.Y);
            Vector2 p8 = new Vector2(p7.X - 0.5 * bdx / 2, p00.Y);
            Vector2 p9 = new Vector2(-p8.X, p8.Y);
            Vector2 p10 = new Vector2(-p7.X, p7.Y);
            Vector2 p11 = new Vector2(-p6.X, p6.Y);
            Vector2 p12 = new Vector2(-p5.X, p5.Y);
            Vector2 p13 = new Vector2(-p4.X, p4.Y);
            Vector2 p14 = new Vector2(-p3.X, p3.Y);
            Vector2 p15 = new Vector2(-p2.X, p2.Y);
            Vector2 p16 = new Vector2(-p1.X, p1.Y);
            Vector2 p17 = new Vector2(p00.X, p12.Y - lsc);

            Vector2[] dotline1 = { fun.Polar(p00, pi * 1.5, 4), fun.Polar(p01, 0.5 * pi, 4) };
            fun.drawPlinetype(dxf, dotline1, 0.15, centre, Linetype.Center); //dxf文件 线段名字 颜色 线形
            Vector2[] dotline2 = { fun.Polar(p17, pi * 1.0, 4), fun.Polar(p17, 0 * pi, 4) };
            fun.drawPlinetype(dxf, dotline2, 0.15, centre, Linetype.Center);

            LwPolyline poly = new LwPolyline();
            poly.Vertexes.Add(new LwPolylineVertex(p01));
            poly.Vertexes.Add(new LwPolylineVertex(p1));
            poly.Vertexes.Add(new LwPolylineVertex(p2));
            poly.Vertexes.Add(new LwPolylineVertex(p3));
            poly.Vertexes.Add(new LwPolylineVertex(p4));
            poly.Vertexes.Add(new LwPolylineVertex(p5));
            poly.Vertexes.Add(new LwPolylineVertex(p6));
            poly.Vertexes.Add(new LwPolylineVertex(p7));
            poly.Vertexes.Add(new LwPolylineVertex(p8));
            poly.Vertexes.Add(new LwPolylineVertex(p9));
            poly.Vertexes.Add(new LwPolylineVertex(p10));
            poly.Vertexes.Add(new LwPolylineVertex(p11));
            poly.Vertexes.Add(new LwPolylineVertex(p12));
            poly.Vertexes.Add(new LwPolylineVertex(p13));
            poly.Vertexes.Add(new LwPolylineVertex(p14));
            poly.Vertexes.Add(new LwPolylineVertex(p15));
            poly.Vertexes.Add(new LwPolylineVertex(p16));
            poly.Vertexes.Add(new LwPolylineVertex(p01));
            fun.PolyFill(dxf, poly, 0.3, contour);

            Vector2[] xiline1 = { p13, p4 };
            fun.drawPlineOfw(dxf, xiline1, 0.3, contour);
            Vector2[] xiline2 = { p10, p7 };
            fun.drawPlineOfw(dxf, xiline2, 0.3, contour);

            fun.drawcircle(dxf, p17, 0.1 * bdx, 0.3, contour);

            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = 0.5;
            double offset = 7;

            LinearDimension linedim1 = new LinearDimension(new Line(p12, p17), offset * 2, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim1, lsc);

            LinearDimension linedim2 = new LinearDimension(new Line(p00, p01), offset * 4, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim2, oal);

            LinearDimension linedim3 = new LinearDimension(new Line(p14, p17), offset * 3, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim3, lf);

            LinearDimension linedim4 = new LinearDimension(new Line(p5, p6), offset * 1, 270, dimensionStyle);
            fun.dxflinedim(dxf, linedim4, lb);

            LinearDimension linedim6 = new LinearDimension(new Line(p6, p11), offset * 2, 180, dimensionStyle);
            fun.dxflinedim(dxf, linedim6, bdx);


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            Vector2 p0 = new Vector2(0, 0);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }




            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);

        }

        public static void GeometryOfTheNoncuttingPartIncludingTheConnection(Dictionary<string, Object> data)  //微调单元镗头
        {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线

            double pi = Math.PI;

            //double lf = 200.0; //Convert.ToDouble(data["lf"]);
            //double ls = 160.0; //Convert.ToDouble(data["ls"]);
            //double bd = 50.0; //Convert.ToDouble(data["bd"]);
            //double oal = 230.0; //Convert.ToDouble(data["oal"]);
            //double dconms = 63.0; //Convert.ToDouble(data["dconms"]);

            //string path = "E:\\dxfp\\GeometryOfTheNoncuttingPartIncludingTheConnection.dxf"; // Convert.ToString(data["path"]);

            double lf = Convert.ToDouble(data["lf"]);
            double ls = Convert.ToDouble(data["ls"]);
            double bd = Convert.ToDouble(data["bd"]);
            double oal = Convert.ToDouble(data["oal"]);
            double dconms = Convert.ToDouble(data["dconms"]);

            string path = Convert.ToString(data["path"]);

            Vector2 p00 = new Vector2(0, 0);
            Vector2 p01 = fun.Polar(p00, pi * 0.0, oal);
            Vector2 p1 = new Vector2(p00.X, p00.Y + 0.5 * dconms);
            Vector2 p2 = new Vector2(p1.X + ls, p1.Y);
            Vector2 p3 = new Vector2(p2.X + (lf - ls) * 0.3, p00.Y + bd / 2);
            Vector2 p4 = new Vector2(p3.X + (lf - ls) * 0.2, p3.Y);
            Vector2 p5 = new Vector2(p4.X + (lf - ls) * 1, p4.Y);
            Vector2 p6 = new Vector2(p01.X - 1, p5.Y);
            Vector2 p7 = new Vector2(p01.X, p6.Y - 1);
            Vector2 p8 = new Vector2(p7.X, -p7.Y);
            Vector2 p9 = new Vector2(p6.X, -p6.Y);
            Vector2 p10 = new Vector2(p5.X, -p5.Y);
            Vector2 p11 = new Vector2(p4.X, -p4.Y);
            Vector2 p12 = new Vector2(p3.X, -p3.Y);
            Vector2 p13 = new Vector2(p2.X, -p2.Y);
            Vector2 p14 = new Vector2(p1.X, -p1.Y);
            Vector2 p15 = new Vector2(p00.X + 0.1 * ls, p00.Y - 0.25 * dconms);
            Vector2 p16 = new Vector2(p15.X, p15.Y + 0.5 * dconms);
            Vector2 p17 = new Vector2(p16.X + 0.2 * ls, p16.Y);
            Vector2 p18 = new Vector2(p17.X, p15.Y);
            Vector2 p19 = new Vector2(p00.X + lf, p00.Y);

            Vector2[] dotline1 = { fun.Polar(p00, pi * 1.0, 4), fun.Polar(p01, 0.0 * pi, 4) };
            fun.drawPlinetype(dxf, dotline1, 0.15, centre, Linetype.Center); //dxf文件 线段名字 颜色 线形
            Vector2[] dotline2 = { fun.Polar(p19, pi * 1.5, 0.1 * bd + 2), fun.Polar(p19, 0.5 * pi, 0.1 * bd + 2) };
            fun.drawPlinetype(dxf, dotline2, 0.15, centre, Linetype.Center);

            LwPolyline poly = new LwPolyline();
            poly.Vertexes.Add(new LwPolylineVertex(p14));
            poly.Vertexes.Add(new LwPolylineVertex(p1));
            poly.Vertexes.Add(new LwPolylineVertex(p2));
            poly.Vertexes.Add(new LwPolylineVertex(p3));
            poly.Vertexes.Add(new LwPolylineVertex(p4));
            poly.Vertexes[4].Bulge = Math.Tan(16);
            poly.Vertexes.Add(new LwPolylineVertex(p5));
            poly.Vertexes.Add(new LwPolylineVertex(p6));
            poly.Vertexes.Add(new LwPolylineVertex(p7));
            poly.Vertexes.Add(new LwPolylineVertex(p8));
            poly.Vertexes.Add(new LwPolylineVertex(p9));
            poly.Vertexes.Add(new LwPolylineVertex(p10));
            poly.Vertexes[10].Bulge = Math.Tan(16);
            poly.Vertexes.Add(new LwPolylineVertex(p11));
            poly.Vertexes.Add(new LwPolylineVertex(p12));
            poly.Vertexes.Add(new LwPolylineVertex(p13));
            poly.Vertexes.Add(new LwPolylineVertex(p14));
            fun.PolyFill(dxf, poly, 0.3, contour);

            Vector2[] xiline1 = { p15, p16, p17, p18, p15 };
            fun.drawPlineOfw(dxf, xiline1, 0.3, contour);
            Vector2[] xiline2 = { p16, p18 };
            fun.drawPlineOfw(dxf, xiline2, 0.1, contour);
            Vector2[] xiline3 = { p15, p17 };
            fun.drawPlineOfw(dxf, xiline3, 0.1, contour);
            Vector2[] xiline4 = { p2, p13 };
            fun.drawPlineOfw(dxf, xiline4, 0.3, contour);
            Vector2[] xiline5 = { p12, p3 };
            fun.drawPlineOfw(dxf, xiline5, 0.3, contour);
            Vector2[] xiline6 = { p9, p6 };
            fun.drawPlineOfw(dxf, xiline6, 0.3, contour);

            Vector2[] xuline1 = { p4, p11 };
            fun.drawPlinetype(dxf, xuline1, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline2 = { p5, p10 };
            fun.drawPlinetype(dxf, xuline2, 0.15, refin, Linetype.Dashed);

            fun.drawcircle(dxf, p19, 0.1 * bd, 0.3, contour);

            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = 0.5;
            double offset = 7;

            LinearDimension linedim1 = new LinearDimension(new Line(p2, p1), offset * 1, 0, dimensionStyle);
            fun.dxflinedim(dxf, linedim1, ls);

            LinearDimension linedim2 = new LinearDimension(new Line(p9, p14), offset * 1, 180, dimensionStyle);
            fun.dxflinedim(dxf, linedim2, oal);

            LinearDimension linedim3 = new LinearDimension(new Line(p1, p19), offset * 4, 0, dimensionStyle);
            fun.dxflinedim(dxf, linedim3, lf);

            LinearDimension linedim4 = new LinearDimension(new Line(p9, p6), offset * 1, 270, dimensionStyle);
            fun.dxflinedim(dxf, linedim4, bd);

            LinearDimension linedim6 = new LinearDimension(new Line(p14, p1), offset * 1, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim6, dconms);


            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            Vector2 p0 = new Vector2(0, 0);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - offset * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }



            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);

        }

        public static void AssembledSinglepointBridgeTool(Dictionary<string, Object> data)  //单点桥镗刀装配(未画)
        {
            DxfDocument dxf = new DxfDocument();
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线

            double pi = Math.PI;

            //double lf = 200.0; //Convert.ToDouble(data["lf"]);
            //double ls = 160.0; //Convert.ToDouble(data["ls"]);
            //double bd = 50.0; //Convert.ToDouble(data["bd"]);
            //double oal = 230.0; //Convert.ToDouble(data["oal"]);
            //double dconms = 63.0; //Convert.ToDouble(data["dconms"]);

            //string path = "E:\\dxfp\\GeometryOfTheNoncuttingPartIncludingTheConnection.dxf"; // Convert.ToString(data["path"]);

            double lf = Convert.ToDouble(data["lf"]);
            double ls = Convert.ToDouble(data["ls"]);
            double bd = Convert.ToDouble(data["bd"]);
            double oal = Convert.ToDouble(data["oal"]);
            double dconms = Convert.ToDouble(data["dconms"]);

            string path = Convert.ToString(data["path"]);

            Vector2 p00 = new Vector2(0, 0);
            Vector2 p01 = fun.Polar(p00, pi * 0.0, oal);
            Vector2 p1 = new Vector2(p00.X, p00.Y + 0.5 * dconms);
            Vector2 p2 = new Vector2(p1.X + ls, p1.Y);
            Vector2 p3 = new Vector2(p2.X + (lf - ls) * 0.3, p00.Y + bd / 2);
            Vector2 p4 = new Vector2(p3.X + (lf - ls) * 0.2, p3.Y);
            Vector2 p5 = new Vector2(p4.X + (lf - ls) * 1, p4.Y);
            Vector2 p6 = new Vector2(p01.X - 1, p5.Y);
            Vector2 p7 = new Vector2(p01.X, p6.Y - 1);
            Vector2 p8 = new Vector2(p7.X, -p7.Y);
            Vector2 p9 = new Vector2(p6.X, -p6.Y);
            Vector2 p10 = new Vector2(p5.X, -p5.Y);
            Vector2 p11 = new Vector2(p4.X, -p4.Y);
            Vector2 p12 = new Vector2(p3.X, -p3.Y);
            Vector2 p13 = new Vector2(p2.X, -p2.Y);
            Vector2 p14 = new Vector2(p1.X, -p1.Y);
            Vector2 p15 = new Vector2(p00.X + 0.1 * ls, p00.Y - 0.25 * dconms);
            Vector2 p16 = new Vector2(p15.X, p15.Y + 0.5 * dconms);
            Vector2 p17 = new Vector2(p16.X + 0.2 * ls, p16.Y);
            Vector2 p18 = new Vector2(p17.X, p15.Y);
            Vector2 p19 = new Vector2(p00.X + lf, p00.Y);

            Vector2[] dotline1 = { fun.Polar(p00, pi * 1.0, 4), fun.Polar(p01, 0.0 * pi, 4) };
            fun.drawPlinetype(dxf, dotline1, 0.15, centre, Linetype.Center); //dxf文件 线段名字 颜色 线形
            Vector2[] dotline2 = { fun.Polar(p19, pi * 1.5, 0.1 * bd + 2), fun.Polar(p19, 0.5 * pi, 0.1 * bd + 2) };
            fun.drawPlinetype(dxf, dotline2, 0.15, centre, Linetype.Center);

            LwPolyline poly = new LwPolyline();
            poly.Vertexes.Add(new LwPolylineVertex(p14));
            poly.Vertexes.Add(new LwPolylineVertex(p1));
            poly.Vertexes.Add(new LwPolylineVertex(p2));
            poly.Vertexes.Add(new LwPolylineVertex(p3));
            poly.Vertexes.Add(new LwPolylineVertex(p4));
            poly.Vertexes[4].Bulge = Math.Tan(16);
            poly.Vertexes.Add(new LwPolylineVertex(p5));
            poly.Vertexes.Add(new LwPolylineVertex(p6));
            poly.Vertexes.Add(new LwPolylineVertex(p7));
            poly.Vertexes.Add(new LwPolylineVertex(p8));
            poly.Vertexes.Add(new LwPolylineVertex(p9));
            poly.Vertexes.Add(new LwPolylineVertex(p10));
            poly.Vertexes[10].Bulge = Math.Tan(16);
            poly.Vertexes.Add(new LwPolylineVertex(p11));
            poly.Vertexes.Add(new LwPolylineVertex(p12));
            poly.Vertexes.Add(new LwPolylineVertex(p13));
            poly.Vertexes.Add(new LwPolylineVertex(p14));
            fun.PolyFill(dxf, poly, 0.3, contour);

            Vector2[] xiline1 = { p15, p16, p17, p18, p15 };
            fun.drawPlineOfw(dxf, xiline1, 0.3, contour);
            Vector2[] xiline2 = { p16, p18 };
            fun.drawPlineOfw(dxf, xiline2, 0.1, contour);
            Vector2[] xiline3 = { p15, p17 };
            fun.drawPlineOfw(dxf, xiline3, 0.1, contour);
            Vector2[] xiline4 = { p2, p13 };
            fun.drawPlineOfw(dxf, xiline4, 0.3, contour);
            Vector2[] xiline5 = { p12, p3 };
            fun.drawPlineOfw(dxf, xiline5, 0.3, contour);
            Vector2[] xiline6 = { p9, p6 };
            fun.drawPlineOfw(dxf, xiline6, 0.3, contour);



            Vector2[] xuline1 = { p4, p11 };
            fun.drawPlinetype(dxf, xuline1, 0.15, refin, Linetype.Dashed);
            Vector2[] xuline2 = { p5, p10 };
            fun.drawPlinetype(dxf, xuline2, 0.15, refin, Linetype.Dashed);

            fun.drawcircle(dxf, p19, 0.1 * bd, 0.3, contour);

            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            dimensionStyle.TextHeight = 0.5;
            double offset = 7;

            LinearDimension linedim1 = new LinearDimension(new Line(p2, p1), offset * 1, 0, dimensionStyle);
            fun.dxflinedim(dxf, linedim1, ls);

            LinearDimension linedim2 = new LinearDimension(new Line(p9, p14), offset * 1, 180, dimensionStyle);
            fun.dxflinedim(dxf, linedim2, oal);

            LinearDimension linedim3 = new LinearDimension(new Line(p1, p19), offset * 4, 0, dimensionStyle);
            fun.dxflinedim(dxf, linedim3, lf);

            LinearDimension linedim4 = new LinearDimension(new Line(p9, p6), offset * 1, 270, dimensionStyle);
            fun.dxflinedim(dxf, linedim4, bd);

            LinearDimension linedim6 = new LinearDimension(new Line(p14, p1), offset * 1, 90, dimensionStyle);
            fun.dxflinedim(dxf, linedim6, dconms);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);

        }

    }
}
